//
//  StepDiagramCell.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/10/21.
//

import UIKit
import FSPagerView
class StepDiagramCell: FSPagerViewCell {
    var bgView: UIView!
    var imagView: UIImageView!
    var titleLab: UILabel!
    var contentLab: UILabel!
    var contentLab1: UILabel!
    var contentLab2: UILabel!

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = .clear
        self.clipsToBounds = true
        self.contentView.layer.shadowColor = UIColor.clear.cgColor
        self.contentView.layer.shadowRadius = 0
        self.contentView.layer.shadowOpacity = 0
        self.contentView.layer.shadowOffset = .zero
        self.initUI()
    }
    
    func initUI(){
        
        self.bgView = UIImageView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: 195))
        self.bgView.layer.cornerRadius = 8
        self.bgView.clipsToBounds = true
        self.bgView.backgroundColor = .white
        self.contentView.addSubview(self.bgView)
        
        self.imagView = UIImageView(frame: .zero)
        self.bgView.addSubview(self.imagView)
        
        
        self.titleLab = UILabel(frame: CGRect(x: 14, y: 0, width: self.frame.size.width - 28, height: 20))
        self.titleLab.textColor = Theme.mainColor
        self.titleLab.font = UIFont.init(name: Theme.PingFangSCMedium, size: 16)
        self.titleLab.textAlignment = .left
        self.titleLab.numberOfLines = 0
        self.titleLab.lineBreakMode = .byWordWrapping
        self.bgView.addSubview(self.titleLab)
        
        self.contentLab = UILabel(frame: CGRect(x: 14, y: 0, width: self.frame.size.width - 28, height: 60))
        self.contentLab.textColor = Theme.titleLabColor
        self.contentLab.font = UIFont.init(name: Theme.PingFangSCRegular, size: 12)
        self.contentLab.textAlignment = .left
        self.contentLab.numberOfLines = 0
        self.contentLab.lineBreakMode = .byWordWrapping
        self.bgView.addSubview(self.contentLab)
        
        
        self.contentLab1 = UILabel(frame: CGRect(x: 14, y: 0, width: self.frame.size.width - 28, height: 60))
        self.contentLab1.textColor = Theme.titleLabColor
        self.contentLab1.font = UIFont.init(name: Theme.PingFangSCRegular, size: 12)
        self.contentLab1.textAlignment = .left
        self.contentLab1.numberOfLines = 0
        self.contentLab1.lineBreakMode = .byWordWrapping
        self.bgView.addSubview(self.contentLab1)
        
        self.contentLab2 = UILabel(frame: CGRect(x: 14, y: 0, width: self.frame.size.width - 28, height: 60))
        self.contentLab2.textColor = Theme.titleLabColor
        self.contentLab2.font = UIFont.init(name: Theme.PingFangSCRegular, size: 12)
        self.contentLab2.textAlignment = .left
        self.contentLab2.numberOfLines = 0
        self.contentLab2.lineBreakMode = .byWordWrapping
        self.bgView.addSubview(self.contentLab2)
        self.addLayout()
    }
    
    
    func addLayout(){
        self.bgView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        self.imagView.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(14)
            make.width.height.equalTo(80)
        }
        
        self.titleLab.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(self.imagView.snp.right).offset(8)
            make.height.greaterThanOrEqualTo(20)
            make.right.equalTo(-11)
        }
        
        self.contentLab.snp.makeConstraints { make in
            make.top.equalTo(self.titleLab.snp.bottom).offset(8)
            make.left.equalTo(self.imagView.snp.right).offset(8)
            make.right.equalTo(-11)
        }
        
        self.contentLab1.snp.makeConstraints { make in
            make.left.equalTo(self.imagView.snp.right).offset(8)
            make.right.equalTo(-11)
            make.top.equalTo(self.contentLab.snp.bottom).offset(8)
        }
        
        self.contentLab2.snp.makeConstraints { make in
            make.left.equalTo(self.imagView.snp.right).offset(8)
            make.right.equalTo(-11)
            make.top.equalTo(self.contentLab1.snp.bottom).offset(8)
            make.bottom.lessThanOrEqualTo(-20)
        }
    }
    
    //setModel
    func setModel(model: VideoVRPdfModel){
        self.imagView.image = UIImage(named: model.image ?? "")
        self.titleLab.text = model.name ?? ""
        self.contentLab.text = model.content ?? ""
        self.contentLab1.text = model.content1 ?? ""
        self.contentLab2.text = model.content2 ?? ""
        
        self.updateConstraints()
        self.layoutIfNeeded()
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
   
}
